<template>
	<!-- 合同  不包含需续费合同 -->
	<div class="app-container" v-loading="loading">
		<!-- 使用搜索组件 -->
		<searchOption id="searchForm" ref="searchUnit" type="contract" :total="total" :isPay="queryParams.isPay"
			:status="queryParams.status" @searchList="parentSearchList"></searchOption>

		<!-- :checkbox-config="{ visibleMethod: showCheckboxkMethod }" -->
		<vxe-table border ref="xTable" size="mini" show-overflow :data="infoList" :column-config="{ resizable: true }"
			:edit-config="{ trigger: 'click', mode: 'cell' }" @scroll="srcollFn" :height="autoTableHeight">
			<!-- type="checkbox"  -->
			<vxe-column field="dispatchDate" title="派单日期" width="90" :visible="queryParams.contractStatus == 4">
				<template #default="{ row }">
					<span>{{ row.dispatchDate }}</span>
				</template>
			</vxe-column>
			<vxe-column field="contractType" title="合同类别" width="70">
				<template #default="{ row }">
					<dict-tag style="display: inline;" :options="dict.type.contract_type" :value="row.contractType" />
				</template>
			</vxe-column>

			<vxe-column title="新签/续费" width="70" :visible="queryParams.contractStatus == 2 || queryParams.isPay == 1">
				<template #default="{ row }">
					<span>{{ (row.isDue == 0 || row.isDue == null) ? '新签' : '续费' }}</span>
				</template>
			</vxe-column>

			<vxe-column title="合同图片" width="70">
				<template #default="{ row }">
					<el-button @click="showPdfDialog(row, true)" type="text">查看合同</el-button>
				</template>
			</vxe-column>

			<vxe-column title="申请盖章" width="70" :visible="queryParams.contractStatus == 2 || queryParams.isPay == 1">
				<template #default="{ row }">
					<el-button @click="askStampClick(row, 1)" :style="{ color: sealStatusType(row.sealStatus) }" type="text">{{
						formatStatus(row.sealStatus)
					}}</el-button>
				</template>
			</vxe-column>

			<vxe-column field="customManager" title="销售经理" width="70">
				<template #default="{ row }">
					{{ row.customManager }}
				</template>
			</vxe-column>

			<vxe-column title="回传合同" width="70" :visible="queryParams.isPay == 1">
				<template #default="{ row }">
					<el-button @click="showPdfDialog(row, true, 1)" v-if="row.backSendUrl !== null" type="text">查看合同</el-button>
				</template>
			</vxe-column>

			<vxe-column title="下载" width="50" :visible="queryParams.contractStatus == 2 || queryParams.isPay == 1">
				<template #default="{ row }">
					<el-button size="mini" type="text" @click="downloadContract(row)">下载</el-button>
				</template>
			</vxe-column>

			<vxe-column title="打印" width="50" :visible="queryParams.contractStatus == 2 || queryParams.isPay == 1">
				<template #default="{ row }">
					<el-button size="mini" type="text" @click="showPdfDialog(row, false)">打印</el-button>
				</template>
			</vxe-column>

			<vxe-column field="bussionEntrustText" title="业务描述" width="70" :visible="queryParams.contractStatus == 4">
				<template #default="{ row }">
					<!-- <el-button @click="showPdfDialog2(row)" type="text">查看描述</el-button> -->
					<el-popover placement="bottom" width="70%" v-if="row.dispatchDate !== null" trigger="hover"
						@show="popoverFc(row, 2)">
						<span slot="reference" style="color: #1890ff;">查看描述</span>
						<img v-if="imageSrc !== ''" :src="imageSrc" />
					</el-popover>
				</template>
			</vxe-column>

			<!--  :visible="queryParams.contractStatus == 4 || queryParams.isPay == 1" -->
			<vxe-column field="" title="服务项目" width="70">
				<template #default="{ row }">
					<el-popover placement="bottom" width="50%" title="服务项目" trigger="hover" content="" transition="fade-in-linear"
						@show="showServiceItems(row.id)">
						<span slot="reference" style="color: #1890ff;">服务项目</span>
						<div style="padding: 0px;">
							<span style="white-space: pre-line" v-html="ServiceItemText"></span>
						</div>
					</el-popover>
				</template>
			</vxe-column>

			<vxe-column field="isBack" title="是否回传" width="70" :visible="queryParams.isPay == 1">
				<template #default="{ row }">
					<span>{{ formatDegree(row.isBack) }}</span>
				</template>
			</vxe-column>

			<!-- customName -->
			<vxe-column field="customName" title="公司名称" width="230">
				<template #default="{ row }">
					{{ row.partyName }}
				</template>
			</vxe-column>

			<vxe-column field="callName" title="联系人" width="70">
				<template #default="{ row }">
					{{ row.partyCallName }}
				</template>
			</vxe-column>

			<vxe-column field="callPhone" title="联系电话" width="100">
				<template #default="{ row }">
					{{ row.partyCallPhone }}
				</template>
			</vxe-column>

			<vxe-column field="paymentDate" title="回款时间" width="90"
				:visible="queryParams.isPay == 1 || queryParams.contractStatus == 2">
				<template #default="{ row }">
					<span>{{ parseTime(row.paymentDate, "{y}-{m}-{d}") }}</span>
				</template>
			</vxe-column>

			<vxe-column field="entrustCycleStrat" title="服务开始日期" width="90">
				<template #default="{ row }">
					<span>{{ parseTime(row.entrustCycleStrat, "{y}-{m}-{d}") }}</span>
				</template>
			</vxe-column>

			<vxe-column field="entrustCycleEnd" title="服务结束日期" width="90">
				<template #default="{ row }">
					<span>{{ parseTime(row.entrustCycleEnd, "{y}-{m}-{d}") }}</span>
				</template>
			</vxe-column>

			<vxe-column field="contractAmount" title="合同金额" width="70">
				<template #default="{ row }">
					{{ row.contractAmount }}
				</template>
			</vxe-column>

			<vxe-column field="paidAmount" title="已付金额" width="70">
				<template #default="{ row }">
					<span>{{ row.paidAmount == null ? 0 : row.paidAmount }}</span>
				</template>
			</vxe-column>

			<vxe-column field="unPaidAmount" title="未付金额" width="70">
				<template #default="{ row }">
					<span :style="{ color: row.unPaidAmount > 0 || row.contractAmount > 0 ? 'red' : '' }">
						{{ row.unPaidAmount == null ? row.contractAmount : row.unPaidAmount }}</span>
				</template>
			</vxe-column>

			<vxe-column field="stepDays" title="回款周期" width="70">
				<template #default="{ row }">
					<span style="color:red">{{ row.stepDays == null ? 0 : row.stepDays }}</span>
				</template>
			</vxe-column>

			<!-- <vxe-column field="remark" title="回款备注" width="150"
				:visible="queryParams.contractType == 2 || queryParams.contractType == 10">
				<template #default="{ row }">
					<span>{{ row.remark }}</span>
				</template>
			</vxe-column> -->

			<vxe-column field="backRemark" title="备注" width="150" :visible="queryParams.contractStatus == 4">
				<template #default="{ row }">
					<span>{{ row.backRemark }}</span>
				</template>
			</vxe-column>

			<vxe-column field="contractNotes" title="作废原因" width="150" :visible="queryParams.contractStatus == 6">
				<template #default="{ row }">
					<span>{{ row.contractNotes }}</span>
				</template>
			</vxe-column>

			<!-- 待回款  已回款  待处理-->
			<vxe-column title="操作" width="80"
				:visible="(queryParams.contractStatus == 2 || queryParams.contractStatus == 3 || queryParams.isPay == 1) && !queryParams.type">
				<template #default="{ row }">
					<el-dropdown @command="handleCommand($event, row)">
						<span class="el-dropdown-link">
							操作选项<i class="el-icon-arrow-down el-icon--right"></i>
						</span>
						<!-- 托管   非托管 -->
						<el-dropdown-menu slot="dropdown" v-if="queryParams.contractStatus == 2 || queryParams.isPay == 1">
							<el-dropdown-item command="1" :disabled="row.unPaidAmount <= 0">添加回款</el-dropdown-item>
							<el-dropdown-item divided command="2" v-if="queryParams.isPay == 1">查看回款记录</el-dropdown-item>
							<el-dropdown-item divided command="3">修改合同</el-dropdown-item>
							<el-dropdown-item divided command="4">作废</el-dropdown-item>
							<el-dropdown-item divided command="7" v-if="queryParams.isPay == 1">回传合同</el-dropdown-item>
							<el-dropdown-item divided command="8"
								v-if="queryParams.isPay == 1 && row.contractType !== 2">提交审核</el-dropdown-item>
						</el-dropdown-menu>
						<!-- 待处理合同 -->
						<el-dropdown-menu slot="dropdown" v-if="queryParams.contractStatus == 3">
							<el-dropdown-item command="5">内勤派单</el-dropdown-item>
							<el-dropdown-item divided command="6">特勤派单</el-dropdown-item>
						</el-dropdown-menu>
					</el-dropdown>
				</template>
			</vxe-column>

			<!-- 处理中合同的操作 -->
			<vxe-column title="操作" :visible="queryParams.contractStatus == 4" width="150">
				<template #default="{ row }">
					<!-- <el-button size="mini" type="text" icon="iconfont ali-iconhuichuan"
						@click="goBankContract(row)">回传合同</el-button> -->
					<el-button size="mini" type="text" icon="iconfont ali-iconzuofei" @click="cancelBtn(row, 6)">作废</el-button>
					<el-button size="mini" type="text" icon="iconfont ali-icontijiao"
						@click="modifyDispatch(row)">修改业务</el-button>
					<!-- <el-button v-if="row.contractType !== 2" size="mini" type="text" icon="iconfont ali-icontijiao"
						@click="submitAuditing(row, 2)">提交审核</el-button> -->
				</template>
			</vxe-column>
			<!-- 申请作废列表的操作 -->
			<vxe-column title="操作" width="150" :visible="queryParams.contractStatus == 6">
				<template #default="{ row }">
					<el-button size="mini" type="text" icon="el-icon-edit" @click="applicationInvalidation(row, 7)">同意</el-button>
					<el-button size="mini" type="text" icon="el-icon-edit" @click="applicationInvalidation(row, 1)">拒绝</el-button>
				</template>
			</vxe-column>
			<!-- 合同列表 修改合同 -->
			<vxe-column title="操作" width="100" :visible="queryParams.type == 1">
				<template #default="{ row }">
					<el-button size="mini" type="text" icon="el-icon-edit" @click="createContract(row)">修改合同</el-button>
				</template>
			</vxe-column>
		</vxe-table>
		<!-- 查看合同弹层 -->
		<el-dialog :visible.sync="pdfDialog.show" title="查看合同">
			<div class="dialog-wrap">
				<div class="item-title">{{ pdfDialog.title }}</div>
				<div class="item-content-wrap">
					<el-scrollbar>
						<div class="item-content">
							<div class="pdf" id="pdfView"></div>
						</div>
					</el-scrollbar>
				</div>
			</div>
		</el-dialog>

		<!-- 添加回款 对话框 -->
		<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body :before-close="cancel">
			<el-form ref="form" :model="form" :rules="rules" label-width="80px">
				<el-row style="margin: 0%;">
					<el-col :span="8">
						<el-form-item label="合同金额">
							{{ contractAmount }}
						</el-form-item>
					</el-col>
				</el-row>
				<el-row style="margin: 0%;">
					<el-col :span="10">
						<el-form-item label="回款金额" prop="paidAmount">
							<el-input v-model="form.paidAmount" type="number" placeholder="请输入金额" @input="maxAmount(form.paidAmount)"
								class="def-input-number" @keydown.native.down.prevent @mousewheel.native.prevent />
						</el-form-item>
					</el-col>
					<el-col :span="14">
						<el-form-item label="回款日期" prop="paymentDate">
							<el-date-picker style="width: 100%;height: 36px;" v-model="form.paymentDate" type="datetime"
								placeholder="选择日期" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
								:picker-options="pickerOptions2">
							</el-date-picker>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row style="margin: 0%;">
					<el-col :span="24">
						<el-form-item label="回款明细" prop="paymentReason">
							<!-- <el-select v-model="form.paymentReason" placeholder="请选择回款明细" style="width: 100%">
						<el-option v-for="dict in paymentReasonOptions" :key="dict.label" :label="dict.label" :value="dict.label" />
					</el-select> -->
							<el-radio-group v-model="form.paymentReason">
								<el-radio v-for="dict in paymentReasonOptions" :key="dict.label" :label="dict.label"
									:value="dict.label">
									{{ dict.label }}
								</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row style="margin: 0%;">
					<el-col :span="24">
						<el-form-item label="付款类型" prop="paymentType">
							<el-radio-group v-model="form.paymentType" @change="paymentTypeChange">
								<el-radio v-for="dict in paymentTypeRadio" :key="dict.value" :label="dict.value" :value="dict.value">{{
									dict.label }}
								</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row style="margin: 0%;">
					<el-form-item label="收款主体" prop="mainName">
						<el-select clearable v-model="form.mainName" style="width: 100%">
							<el-option v-for="  item of mainNameList  " :key="item.id" :label="item.companyName"
								:value="item.id"></el-option>
						</el-select>
					</el-form-item>
				</el-row>
				<el-row style="margin: 0%;">
					<el-form-item label="回款凭证" prop="file">
						<el-upload action="#" ref="uploadExcel" list-type="picture-card" :headers="headers" :file-list="fileList"
							:http-request="uploadFile" drag accept=".jpeg,.jpg,.png" :on-preview="handlePictureCardPreview"
							:on-remove="handleRemove" :on-error="imgUploadError" :on-success="imgUploadSuccess">
							<i class="el-icon-plus"></i>
						</el-upload>
						<el-dialog :visible.sync="dialogVisible">
							<img width="100%" :src="dialogImageUrl" alt="">
						</el-dialog>
					</el-form-item>
				</el-row>
				<el-row>
					<el-col :span="24">
						<el-form-item label="回款备注">
							<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitForm">确 定</el-button>
				<el-button @click="cancel">取 消</el-button>
			</div>
		</el-dialog>

		<!-- 修改合同对话框 -->
		<el-dialog title="生成合同" :visible.sync="openContract" width="60%" append-to-body :close-on-click-modal="false">
			<contract-dia ref="contractDiaRef" @closeDialog="cancelContract" :rowObj="rowObj"></contract-dia>
		</el-dialog>

		<!-- 查看回款记录 -->
		<el-dialog title="查看回款记录" :visible.sync="openPayment" width="50%" append-to-body>
			<vxe-table border ref="xTable" size="mini" show-overflow :data="paymentList" :column-config="{ resizable: false }"
				:edit-config="{ trigger: 'click', mode: 'cell' }" height="750px">
				<vxe-column field="paidAmount" title="金额" width="70">
					<template #default="{ row }">
						<span>{{ row.paidAmount }}</span>
					</template>
				</vxe-column>
				<vxe-column field="paymentReason" title="回款明细" width="70">
					<template #default="{ row }">
						<span>{{ row.paymentReason }}</span>
					</template>
				</vxe-column>
				<vxe-column field="paymentType" title="付款类型" width="70">
					<template #default="{ row }">
						<span v-if="row.paymentType === 1">扫码</span>
						<span v-if="row.paymentType === 2">对公</span>
						<span v-if="row.paymentType === 3">现金</span>
					</template>
				</vxe-column>
				<!-- 1:天津浦颂企业管理咨询有限公司  2:天津浦颂财税服务有限公司-->
				<vxe-column field="mainName" title="收款主体">
					<template #default="{ row }">
						<span>{{ mainNameList[row.mainName == 1 ? 0 : 1].companyName }}</span>
					</template>
				</vxe-column>
				<vxe-column field="remark" title="回款备注" width="150">
					<template #default="{ row }">
						<span>{{ row.remark }}</span>
					</template>
				</vxe-column>
				<vxe-column field="file" title="回款凭证" width="70">
					<template #default="{ row }">
						<el-popover placement="bottom" width="475" v-if="row.paymentImageUrl !== null" trigger="hover"
							@show="popoverFc(row, 1)">
							<span slot="reference" style="color: #1890ff">查看图片</span>
							<img v-if="imageSrc !== ''" :src="imageSrc" style="width: 450px" />
						</el-popover>
					</template>
				</vxe-column>
				<vxe-column field="gmtCreate" title="回款时间" width="130">
					<template #default="{ row }">
						<span>{{ row.gmtCreate }}</span>
					</template>
				</vxe-column>
			</vxe-table>
		</el-dialog>
		<!-- 内外勤 派单 -->
		<el-dialog ref="insideTaskRef" :visible.sync="insideTaskVis" :modal="true" width="50%" :close-on-click-modal="false"
			:title="taskVisTitle" append-to-body>
			<el-form ref="elForm" :model="form" :rules="dispatchRules" size="medium" label-width="135px">
				<el-form-item label="基础类别" prop="contractTypeArr" v-if="dispatchType == 'add'">
					<el-checkbox-group v-model="form.selectList">
						<el-checkbox v-for="dict in dict.type.contract_type" :key="dict.value" :label="dict.value">{{ dict.label }}
						</el-checkbox>
					</el-checkbox-group>
				</el-form-item>
				<el-row style="margin: 0%;">
					<el-col v-for="item of dispatchData" :key="item.name" :span="item.span">
						<el-form-item :label="item.label" :prop="item.name"
							v-if="item.name == 'gmtCreate' ? dispatchType == 'add' ? true : false : true">
							<el-radio-group v-if="item.radio" v-model="item.value" @change="radioChange(item)"
								:disabled="item.name == 'paymentType'">
								<el-radio v-for="item2 of item.children" :key="item2.label" :label="item2.label">{{ item2.name
									}}</el-radio>
							</el-radio-group>
							<el-date-picker v-else-if="item.date" style="width: 160px;" v-model="item.value" type="date" size="mini"
								:placeholder="item.placeholder" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
								:picker-options="pickerOptions1">
							</el-date-picker>
							<el-input v-else size="mini" :type="item.textarea ? 'textarea' : ''" :placeholder="item.placeholder"
								v-model="item.value" style="margin-top: 4px" :style="{ width: item.textarea ? 'none' : '100%' }"
								@input="dispatchEvent(item)">
							</el-input>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer">
				<el-button @click="insideTaskFormClose"> 取消 </el-button>
				<el-button type="primary" @click="insideTaskFormConfirm">确定</el-button>
			</div>
		</el-dialog>

		<!-- 待回传合同 -->
		<el-dialog ref="previewPdf" :visible.sync="fileOpen" :modal="true" width="24%" title="回传合同" append-to-body>
			<el-upload class="upload-demo" drag :action="uploadImgUrl" :headers="headers" :on-success="getList" multiple
				accept=".pdf" :data="{ customId: this.form.customId, type: 11 }">
				<i class="el-icon-upload"></i>
				<div class="el-upload__text">将pdf文件拖到此处，或<em>点击上传</em></div>
				<div class="el-upload__tip" slot="tip">只能上传pdf文件</div>
			</el-upload>
		</el-dialog>
		<!-- 处理中的合同  非托管类合同  提交审核时添加备注 -->
		<el-dialog title="提交审核" :visible.sync="notesShow" width="500px" append-to-body :before-close="cancel">
			<el-form ref="formRemark" :model="formRemark" :rules="notesRules" label-width="80px">
				<el-form-item label="备注" prop="remark">
					<el-input v-model="formRemark.remark" type="textarea" placeholder="请输入内容" />
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="askStampClick(formRemark.row, formRemark.type)">确 定</el-button>
				<el-button @click="cancel">取 消</el-button>
			</div>
		</el-dialog>
		<!-- 申请作废 -->
		<el-dialog title="申请作废" :visible.sync="cancellationShow" width="500px" append-to-body :before-close="cancel">
			<el-form ref="formRemark" :model="formRemark" label-width="80px">
				<el-form-item label="作废原因" prop="remark">
					<el-input v-model="formRemark.cancelRemark" type="textarea" placeholder="请输入内容" />
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="cancellationSubmit(formRemark.row, formRemark.status)">确 定</el-button>
				<el-button @click="cancel">取 消</el-button>
			</div>
		</el-dialog>

	</div>
</template>

<script>
import {
	listInfo,
	getInfo,
	delInfo,
	addInfo,
	updateInfo,
	openPDF,
	loadImage,
	askStamp,
	allList,
	serviceItems,
	contractItem,
	taskInfo,
	updateTask
} from "@/api/contract/info";
import { addTask } from "@/api/system/task";
import { addStep, listStep } from "@/api/system/step";
import { getToken } from "@/utils/auth";

//生成合同
import { pcaTextArr } from "element-china-area-data";
import { addDetail, getPartyBOptions } from "@/api/system/detail";
import Pdfh5 from "pdfh5";
import "pdfh5/css/pdfh5.css";
import ContractDia from "@/components/ContractDia";
import { operate } from "@/api/outsideTask/inSidetask";
import searchOption from "@/components/searchOption";

export default {
	components: {
		ContractDia,
		searchOption
	},
	name: "Info",
	dicts: ["contract_type"],
	data() {
		var checkLegalPersonIdCard = (rule, value, callback) => {
			// value = this.form.legalPersonIdCard;
			value = this.getValueByName('legalPersonIdCard');
			const idCardReg =
				/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}([0-9]|X|x)$/;
			if (!idCardReg.test(value)) {
				// 校验失败，调用 callback 并传入一个 Error 对象
				callback(new Error("身份证号格式不正确"));
			} else {
				// 校验成功，调用 callback 不传入任何参数
				callback();
			}
		};

		var checkLegalPersonPhone = (rule, value, callback) => {
			// value = this.form.legalPersonPhone;
			value = this.getValueByName('legalPersonPhone');
			const phoneReg = /^1[3-9]\d{9}$/; // 匹配中国手机号格式
			if (!phoneReg.test(value)) {
				// 校验失败，调用 callback 并传入一个 Error 对象
				callback(new Error("手机号格式不正确"));
			} else {
				// 校验成功，调用 callback 不传入任何参数
				callback();
			}
		};
		return {
			requeryFlag: true,
			// 派单--修改或新增 modify / add
			dispatchType: '',
			autoTableHeight: 750,
			// 服务项目明细
			ServiceItemText: '',
			dialogImageUrl: '',
			dialogVisible: false,
			// 打印pdf临时路径
			printPdfUrl: null,
			// 当前合同金额
			contractAmount: 0,
			pcaTextArr,
			// 遮罩层
			loading: true,
			// 选中数组
			ids: [],
			// 非多个禁用
			multiple: true,
			// 总条数
			total: 0,
			//表格数据
			infoList: [],
			// 弹出层标题
			title: "回款金额回填",
			// 是否显示弹出层
			open: false,
			// 查询参数
			queryParams: {
				pageNum: 1,
				pageSize: 30,
				contractType: 10,
				contractStatus: null,
			},
			// 表单参数
			form: {
				remark: '',
				paymentDate: '',
				paidAmount: "",
				customId: 0,
				paymentReason: "",
				contractId: 0,
				paymentType: "",
				mainName: "",
				// 内勤派单 合同类别
				selectList: [],
				companyName: "",
				callName: "",
				callPhone: "",
				taskType: "",


				legalPersonName: "",
				legalPersonIdCard: "",
				investmentRate: "",
				registerAmount: "",
				openBankName: "",
				region: "",
				customScene: "",
				paymentType: "",
				proxyIs: "",
				getCustomFile: "",
				legalPersonInfo: "",
				supervisor: "",
				addressInfo: "",
				scope: "",
				taskList: "",
				legalPersonPhone: "",
			},
			// 派单对话框
			insideTaskVis: false,
			// 派单对话标题
			taskVisTitle: '',
			// 派单结构数据
			dispatchData: [
				{ label: '公司名称', name: 'companyName', value: '', span: 24, placeholder: '请输入公司名称' },
				// { label: '注册资金', name: 'registerAmount', value: '', span: 12, placeholder: '请输入注册资金' },
				{ label: '客户联系人', name: 'callName', value: '', span: 12, placeholder: '请输入客户联系人' },
				{ label: '客户联系电话', name: 'callPhone', value: '', span: 12, placeholder: '请输入客户联系电话' },
				{ label: '法人姓名', name: 'legalPersonName', value: '', span: 12, placeholder: '请输入法人' },
				{ label: '法人联系电话', name: 'legalPersonPhone', value: '', span: 12, placeholder: '请输入法人电话' },
				{ label: '法人身份证', name: 'legalPersonIdCard', value: '', span: 12, placeholder: '请输入法人身份证' },
				{ label: '开户银行', name: 'openBankName', value: '', span: 12, placeholder: '请输入开户银行' },
				{
					label: '已收款项', name: 'paymentType', value: '', span: 12, radio: true, children: [
						{ label: 0, name: '定金', },
						{ label: 1, name: '全款' },
					]
				},
				{
					label: '客户是否到场', name: 'customScene', value: '', span: 12, radio: true, children: [
						{ label: 0, name: '是', },
						{ label: 1, name: '否' },
					]
				},
				{
					label: '是否代账', name: 'proxyIs', value: '', span: 12, radio: true, children: [
						{ label: 0, name: '是', },
						{ label: 1, name: '否' },
					]
				},
				{ label: '所属区域', name: 'region', value: '', span: 12, placeholder: '请输入派单区域' },
				// { label: '各股东投资比例', name: 'investmentRate', value: '', span: 12, placeholder: '请输入投资比例' },
				// { label: '派单日期', name: 'gmtCreate', value: '', span: 12, textarea: false, placeholder: '请选择派单日期', date: true },
				{ label: '办理事项', name: 'taskList', value: '', span: 24, textarea: true, placeholder: '请输入办理事项' },
				{ label: '收到客户材料', name: 'getCustomFile', value: '', span: 24, textarea: true, placeholder: '请输入收到客户材料' },
				// { label: '法人股东身份信息', name: 'legalPersonInfo', value: '', span: 24, textarea: true, placeholder: '请输入法人股东身份信息' },
				// { label: '监事信息', name: 'supervisor', value: '', span: 24, textarea: true, placeholder: '请输入监事信息' },
				// { label: '注册地址', name: 'addressInfo', value: '', span: 24, textarea: true, placeholder: '请输入注册地址' },
				// { label: '经营范围', name: 'scope', value: '', span: 24, textarea: true, placeholder: '请输入经营范围' },
			],
			pickerOptions1: {
				disabledDate(time) {
					return time.getTime() > Date.now();
				}
			},
			pickerOptions2: {
				disabledDate(time) {
					return time.getTime() > Date.now();
				},
				shortcuts: [{
					text: '今天',
					onClick(picker) {
						picker.$emit('pick', new Date());
					}
				}, {
					text: '昨天',
					onClick(picker) {
						const date = new Date();
						date.setTime(date.getTime() - 3600 * 1000 * 24);
						picker.$emit('pick', date);
					}
				}]
			},
			// 表单校验
			rules: {
				paidAmount: {
					required: true,
					message: "请填写回款金额",
					trigger: "blur",
				},
				paymentDate: {
					required: true,
					message: "请选择回款日期",
					trigger: "blur",
				},
				paymentReason: {
					required: true,
					message: "请选择回款明细",
					trigger: "change",
				},
				paymentType: {
					required: true,
					message: "请选择收款类型",
					trigger: "change",
				},
				mainName: {
					required: true,
					message: "请选择收款主体",
					trigger: "change",
				}
			},
			// 内勤派单表单校验
			dispatchRules: {
				legalPersonIdCard: {
					required: true,
					message: "",
					trigger: "blur",
					validator: checkLegalPersonIdCard,
				},
				legalPersonPhone: {
					required: true,
					message: "",
					trigger: "blur",
					validator: checkLegalPersonPhone,
				},
				contractTypeArr: {
					required: true,
					message: "请选择合同类别",
					trigger: "change",
					validator: (rule, value, callback) => {
						value = this.form.selectList;
						if (value.length > 0) {
							callback();
						} else {
							callback(new Error("请选择合同类别"));
						}
					}
				},
				proxyIs: {
					required: true,
					message: "",
					trigger: "change",
					validator: (rule, value, callback) => {
						value = this.getValueByName('proxyIs');
						if (value !== null && value !== '') {
							callback();
						} else {
							callback(new Error("请选择是否代账"));
						}
					}
				},
				region: {
					required: true,
					message: "",
					trigger: "blur",
					validator: (rule, value, callback) => {
						value = this.getValueByName('region')
						if (value !== null && value !== '') {
							callback();
						} else {
							callback(new Error("请输入派单区域"));
						}
					}
				},
				legalPersonName: {
					required: true,
					message: "",
					trigger: "blur",
					validator: (rule, value, callback) => {
						value = this.getValueByName('legalPersonName')
						if (value !== null && value !== '') {
							callback();
						} else {
							callback(new Error("请输入法人"));
						}
					}
				},
				taskList: {
					required: true,
					message: "",
					trigger: "blur",
					validator: (rule, value, callback) => {
						value = this.getValueByName('taskList')
						if (value !== null && value !== '') {
							callback();
						} else {
							callback(new Error("请输入办理事项"));
						}
					}
				}
			},
			// 处理中合同 提交审核的备注  校验
			notesRules: {
				remark: {
					required: true,
					message: "请输入备注",
					trigger: "blur",
				},
			},
			unPaidAmount: 0,
			//打开 生成合同的对话框
			openContract: false,
			rowId: undefined,
			paymentList: undefined,
			openPayment: false,
			headers: {
				Authorization: "Bearer " + getToken(),
			},

			uploadImgUrl: process.env.VUE_APP_BASE_API + "/custom/info/uploadContract",
			fileList: [],
			fileData: "",
			file: "",
			paymentTypeRadio: [
				{ value: 1, label: "扫码" },
				{ value: 2, label: "对公" },
				{ value: 3, label: "现金" },
			],
			mainNameList: [],
			paymentReasonOptions: [
				{ value: 1, label: "全款" },
				{ value: 2, label: "首款" },
				{ value: 3, label: "中期" },
				{ value: 4, label: "尾款" },
			],
			pdfDialog: {
				show: false,
				title: "",
			},
			pdfh5: null,
			rowObj: {},
			imageSrc: "",
			// 处理中合同  待回传合同弹层
			fileOpen: false,
			cancellationShow: false,
			formRemark: {
				cancelRemark: '',
				remark: '基础业务客户，不需要回传',
			},
			notesShow: false,
			// 合同列表flag
			hetongFlag: false,
		};
	},
	mounted() {
		this.$nextTick(() => {
			// 视口高度 - 列表上方的元素高度
			let allHeight = window.innerHeight;
			let element = [
				document.getElementById('navbar'),
				document.getElementById('searchForm'),
				document.getElementById('tags-view-container'),
			]
			let domHeight = element.map(item => item.offsetHeight)
			// let tableHeight = allHeight - 50 - 34 - 50 - 36;
			let tableHeight = allHeight - 40 - domHeight[0] - domHeight[1] - domHeight[2];
			this.autoTableHeight = tableHeight;
		})
	},
	watch: {
		// 监听路由对象中的变化
		'$route': {
			handler: function (from, to) {
				// 当路由发生变化时会调用这个函数
				this.infoList = [];
				this.queryParams.pageNum = 1;
				this.queryParams.pageSize = 30;
				this.queryParams.customName = null;
				this.queryParams.callPhone = null;
				this.queryParams.callName = null;
				this.queryParams.customManager = null;
				this.queryParams.isPay = from.query.isPay;
				this.queryParams.contractType = from.query.contractType;
				this.queryParams.contractType_copy = from.query.contractType;
				this.queryParams.contractStatus = from.query.contractStatus ? from.query.contractStatus : null;
				this.queryParams.type = from.query.type;
				// type为1时，表示合同列表，调用listAll接口
				if (from.query.type == 1) {
					this.hetongFlag = true;
					this.getAllList();
				} else {
					this.hetongFlag = false;
					this.getList();
				}
				this.$nextTick(() => {
					// 待回款  非托管类合同 搜索条件的合同类别 禁用托管类合同选项
					if (from.query.contractType == 10 && (from.query.contractStatus == 2 || from.query.contractStatus == 5 || from.query.isPay == 1)) {
						this.$refs.searchUnit.optionDisabled = true;
					} else {
						this.$refs.searchUnit.optionDisabled = false;
					}
					// 待回款  托管类合同 搜索条件的合同类别 隐藏
					if (from.query.contractType == 2 && (from.query.contractStatus == 2 || from.query.contractStatus == 5 || from.query.isPay == 1)) {
						this.$refs.searchUnit.hide = true;
					} else {
						this.$refs.searchUnit.hide = false;
					}
					if (from.query.isPay == 1) {
						this.$refs.searchUnit.getContractCount(this.$store.state.user.name);
					}
				});
			},
			// 如果需要在路由变化时立即响应，可以设置immediate为true
			immediate: true
		}
	},
	created() {
		this.getPartyBOptions();
	},
	methods: {
		// 根据条件显示复选框
		showCheckboxkMethod({ row }) {
			return this.queryParams.contractStatus == 6;
		},
		// 根据name属性，查找出value值
		getValueByName(name) {
			let value = '';
			this.dispatchData.forEach(item => {
				if (item.name == name) {
					value = item.value;
				}
			});
			return value;
		},
		// 搜索子组件触发搜索
		parentSearchList(data) {
			this.queryParams.pageNum = data.pageNum;
			this.queryParams.pageSize = data.pageSize;
			this.queryParams.callName = data.callName;
			this.queryParams.callPhone = data.callPhone;
			this.queryParams.customName = data.customName;
			this.queryParams.contractType = data.contractType !== null && data.contractType !== "" ?
				data.contractType : data.contractTypeFlag ? this.queryParams.contractType_copy : this.queryParams.contractType;
			this.queryParams.customManager = data.customManager;
			this.handleQuery();
		},
		// 是否已回传
		formatDegree(value) {
			if (value == "0") {
				return "未回传";
			}
			if (value == "1") {
				return "已回传";
			}
			return "";
		},
		// 回款金额不能大于合同金额
		maxAmount(amount) {
			if (amount > this.unPaidAmount) {
				this.$message.error('回款金额不能大于合同金额')
				return false
			} else {
				return true
			}
		},
		/** 查询列表 */
		getList() {
			this.loading = true;
			listInfo(this.queryParams).then((response) => {
				this.infoList = response.rows;
				this.total = response.total;
				this.loading = false;
			});
		},
		// 合同列表 所有类型列表的查询
		getAllList() {
			this.loading = true;
			allList(this.queryParams).then((response) => {
				this.infoList = response.rows;
				this.total = response.total;
				this.loading = false;
			});
		},
		// 企业主体
		getPartyBOptions() {
			console.log("getPartyBOptions");
			getPartyBOptions().then((response) => {
				this.mainNameList = response.rows;
			});
		},
		// 取消按钮
		cancel() {
			this.open = false;
			// this.reset();
			this.notesShow = false;
			this.formRemark.row = {};
			this.formRemark.type = null;
			// this.formRemark.remark = '';
			this.cancellationShow = false;
		},
		/** 搜索按钮操作 */
		handleQuery() {
			this.queryParams.pageNum = 1;
			if (this.hetongFlag) {
				this.getAllList();
			} else {
				this.getList();
			}
		},
		/** 重置按钮操作 */
		resetQuery() {
			this.resetForm("queryForm");
			this.handleQuery();
		},
		/** 添加汇款记录 */
		handleUpdate(row) {
			this.unPaidAmount = 0;
			// 当前合同的未付金额
			this.unPaidAmount = row.unPaidAmount;
			this.contractAmount = row.contractAmount;
			this.form.contractId = row.id;
			this.form.customId = row.customId;
			this.form.mainName = row.partyB;
			this.open = true;
		},
		/** 提交按钮 */
		submitForm() {
			this.$refs["form"].validate((valid) => {
				if (valid) {
					// 检查回款金额是否高于合同金额
					if (!this.maxAmount(this.form.paidAmount)) {
						return
					}
					this.$refs.uploadExcel.submit();
					//携带文件必须使用此对象
					const formDatas = new FormData();
					console.log("this.file", this.file);
					if (this.file) {
						//append方法逐个添加键值对
						formDatas.append("file", this.file); //把文件实体添加到表单对象
					} else {
						this.$modal.msgError("验证未通过");
						return;
					}
					console.log(formDatas);
					formDatas.append("paidAmount", this.form.paidAmount);
					formDatas.append("paymentReason", this.form.paymentReason);
					formDatas.append("customId", this.form.customId);
					formDatas.append("gmtCreate", this.form.paymentDate);
					formDatas.append("contractId", this.form.contractId);
					formDatas.append("paymentType", this.form.paymentType);
					formDatas.append("mainName", this.form.mainName);
					formDatas.append("remark", this.form.remark);
					addStep(formDatas).then((response) => {
						this.openFc();
						this.getList();
						this.fileList = [];
					});
				} else {
					this.$modal.msgError("验证未通过");
					return false;
				}
			});
		},
		openFc() {
			this.open = false;
			this.form = {
				paidAmount: "",
				customId: 0,
				paymentReason: "",
				contractId: 0,
				paymentType: "",
				mainName: "",
			};
			this.fileList = [];
		},
		paymentTypeChange() {

		},

		/** 导出按钮操作 */
		handleExport() {
			this.download(
				"system/info/export",
				{
					...this.queryParams,
				},
				`info_${new Date().getTime()}.xlsx`
			);
		},

		//修改合同
		createContract(row) {
			this.openContract = true;
			this.rowObj = row;
			this.rowObj.isNew = true;
			this.rowId = row.id;
			this.$nextTick(() => {
				this.$refs.contractDiaRef.reset();
			});
		},
		// 取消按钮
		cancelContract() {
			this.openContract = false;
			this.$refs.contractDiaRef.reset();
			this.getList();
		},

		//查看回款记录
		handleView(row) {
			console.log(row);
			this.openPayment = true;
			let queryParams = {
				pageNum: 1,
				pageSize: 30,
				contractId: row.id,
			};
			listStep(queryParams).then((response) => {
				this.paymentList = response.rows;
			});
		},
		uploadFile(param) {
			console.log(param);
			this.file = param.file;
		},
		// 下载合同
		downloadContract(item) {
			this.$download.downloadFile('/common/downloadFile', item.contractCode + `.pdf`, false, false, item.partyName + item.contractCode + `.pdf`);
		},
		// 预览合同   打印合同
		showPdfDialog(item, printFalg, type) {
			// 先删除由于打印功能而添加的iframe
			const iframe = document.getElementById('printPdf');
			if (iframe) {
				iframe.remove();
			}
			// 如果printFalg为true则打印，否则预览
			if (printFalg) {
				this.pdfDialog.show = true;
			}
			let pdfurl = '';
			// type为1时，查看回传的合同
			if (type == 1) {
				pdfurl = item.backSendUrl;
			} else {
				pdfurl = item.contractCode;
			}
			openPDF(pdfurl).then((response) => {
				if (printFalg) {
					let blob = response;
					let blobURL = window.URL.createObjectURL(blob);
					this.pdfh5 = new Pdfh5("#pdfView", {
						pdfurl: blobURL,
					});
					window.URL.revokeObjectURL(blobURL);
				} else {
					const blob = new Blob([response], {
						type: 'application/pdf'
					})
					var iframe = document.createElement('iframe')
					iframe.style.frameborder = 'no'
					iframe.style.display = 'none'
					iframe.style.pageBreakBefore = 'always'
					iframe.setAttribute('id', 'printPdf')
					iframe.setAttribute('name', 'printPdf')
					iframe.src = window.URL.createObjectURL(blob) //创建一个包含指定对象的URL
					document.body.appendChild(iframe)
					this.doPrint('printPdf')
					window.URL.revokeObjectURL(iframe.src) //释放url
				}
			});
		},
		// 调用浏览器打印API
		doPrint(val) {
			var ordonnance = document.getElementById(val).contentWindow
			setTimeout(() => {
				ordonnance.print()
			}, 500)
		},
		// 查看服务项目
		showServiceItems(id) {
			this.ServiceItemText = '';
			serviceItems(id).then((response) => {
				this.ServiceItemText = response.data.amountOrRemind;
			})
		},
		// 回款记录 查看图片
		popoverFc(row, type) {
			let url = '';
			if (type == 1) {//  1为回款记录的图片
				url = row.paymentImageUrl;
			} else {
				// url = `/task/${row.taskId}.png`;
				url = `/task/${row.id}.png`;
			}
			this.imageSrc = "";
			loadImage(url).then((response) => {
				if (response.type === "image/jpg") {
					const blobData = {};
					blobData.type = "application/image;chartset=UTF-8";
					this.imageSrc = window.URL.createObjectURL(
						new Blob([response], blobData)
					);
				}
			});
		},
		// 作废
		cancelBtn(row, status) {
			this.formRemark.row = row;
			this.formRemark.status = status;
			this.cancellationShow = true;
			// 有任务id传任务id，否则传-1
			// let taskId = row.taskId == null ? -1 : row.taskId;
			// let text = "确认作废吗？";
			// this.$modal
			// 	.confirm(text)
			// 	.then(function () { })
			// 	.then(() => {
			// 		operate(taskId, status, row.id).then((response) => {
			// 			console.log(response);
			// 			if (response.code === 200) {
			// 				this.getList();
			// 			}
			// 		});
			// 	})
			// 	.catch(() => { });
		},
		// 提交作废
		cancellationSubmit(row, status) {
			// 有任务id传任务id，否则传-1
			let taskId = row.taskId == null ? -1 : row.taskId;
			let params = {
				id: row.id,
				taskId: taskId,
				status: status,
				contract_notes: this.formRemark.cancelRemark
			}
			operate(params).then((response) => {
				console.log(response);
				if (response.code === 200) {
					this.cancellationShow = false;
					this.$modal.msgSuccess("操作成功");
					this.getList();
				}
			});
		},
		// 滚动加载
		srcollFn(e) {
			let circulateNum = this.total / 30;
			let bottomOffset = e.scrollHeight - e.scrollTop - e.bodyHeight;
			if (bottomOffset < 50 && this.queryParams.pageNum < circulateNum) {
				if (this.requeryFlag) {
					this.loading = true;
					this.requeryFlag = false;
					this.queryParams.pageNum++;
					if (this.queryParams.type == 1) {
						allList(this.queryParams).then((response) => {
							this.infoList = [...this.infoList, ...response.rows];
							this.loading = false;
							this.requeryFlag = true;
						});
					} else {
						listInfo(this.queryParams).then((response) => {
							this.infoList = [...this.infoList, ...response.rows];
							this.loading = false;
							this.requeryFlag = true;
						});
					}
				}
			}
		},
		// 申请盖章被点击
		askStampClick(row, type) {
			let data = {};
			let that = this;
			let flag = false;
			let sealCode = row.sealStatus
			if (type == 1) {
				switch (sealCode) {
					case 0: case 2:
						flag = true;
						break;
					case 1:
						this.$message.warning('该合同已盖章')
						break;
					case 3:
						this.$message.warning('该合同正在申请盖章')
						break;
					default:
						break;
				}
			}
			if (type == 2) {
				if (this.formRemark.remark.trim() == '') {
					return this.$message.warning('请填写备注');
				}
				switch (row.isBack) {
					case 0:
						flag = true;
						break;
					case 1:
						this.$message.warning('该合同已审核')
						break;
					default:
						flag = true;
						break;
				}
			}
			if (flag) {
				this.$modal
					.confirm(`${type == 1 ? '确认申请盖章吗？' : '确认提交审核吗？'}`)
					.then(function () {
						data.type = type;
						data.contractId = row.id;
						data.customId = row.customId;
						data.callName = row.callName;
						data.callPhone = row.callPhone;
						data.customName = row.partyName;
						data.sealStatus = row.sealStatus;
						data.remark = that.formRemark.remark;
						data.contractCode = row.contractCode;
						data.contractType = row.contractType;
						data.customManager = row.customManager;
						data.contractAmount = row.contractAmount;
						data.entrustCycleEnd = row.entrustCycleEnd;
						data.entrustCycleStrat = row.entrustCycleStrat;
						data.paidAmount = row.paidAmount == null ? 0 : row.paidAmount;
						data.unPaidAmount = row.unPaidAmount == null ? row.contractAmount : row.unPaidAmount;
						return askStamp(data);
					}).then(() => {
						this.$message.success('操作成功！');
						// 更新本地数据
						let xTable = this.$refs.xTable;
						let index = xTable.getRowIndex(row)
						let rowData = this.infoList[index];
						if (type == 1) {
							// 更新本地该数据的盖章状态
							rowData.sealStatus = 3;
							xTable.updateData(rowData)
						} else {
							// 更新备注
							rowData.backRemark = that.formRemark.remark;
							xTable.updateData(rowData)
						}
						this.cancel();
					}).catch(function (err) {
						console.log(err);
					});
			}
		},
		//申请盖章字体颜色
		sealStatusType(value) {
			switch (value) {
				case 0:
					return '#1890ff'
				case 1:
					return '#67C23A'
				case 2:
					return '#F56C6C'
				case 3:
					return '#E6A23C'
				default:
					return '#333';
			}
		},
		// 申请盖章的状态
		formatStatus(value) {
			switch (value) {
				case 0:
					return '申请盖章'
				case 1:
					return '盖章成功'
				case 2:
					return '拒绝盖章'
				case 3:
					return '申请中'
				default:
					return '未知';
			}
		},
		// 操作菜单被点击
		handleCommand(e, row) {
			if (e === '1') {
				this.handleUpdate(row)
			} else if (e === '2') {
				this.handleView(row)
			} else if (e === '3') {
				this.createContract(row)
			} else if (e === '4') {
				this.cancelBtn(row, 6)
			} else if (e === '5') {
				this.dispatchOders(row, 1)
			} else if (e === '6') {
				this.dispatchOders(row, 2)
			} else if (e === '7') {
				this.goBankContract(row)
			} else if (e === '8') {
				this.submitAuditing(row, 2)
			}
		},
		// 上传图片的删除
		handleRemove(file, fileList) {
			console.log(file, fileList);
		},
		// 上传图片的放大预览
		handlePictureCardPreview(file) {
			this.dialogImageUrl = file.url;
			this.dialogVisible = true;
		},
		// 上传失败的回调
		imgUploadError(err, file, fileList) {
			this.$message.error('上传图片失败！');
		},
		// 上传图片成功的回调
		imgUploadSuccess(response, file, fileList) {
			this.form.contractImg = response.data;
		},
		// 处理中的合同 修改业务（修改内勤或外勤的内容）
		modifyDispatch(row) {
			this.reset();
			this.dispatchType = 'modify';
			this.form.companyName = row.partyName;
			this.form.callName = row.callName;
			this.form.callPhone = row.callPhone;
			this.form.contractId = row.id;
			taskInfo(row.id).then(res => {
				let response = res.data;
				for (let key in response) {
					for (let i = 0; i < this.dispatchData.length; i++) {
						if (this.dispatchData[i].name == key) {
							this.dispatchData[i].value = response[key];
							break
						}
					}
				}
				this.insideTaskVis = true;
				this.taskVisTitle = "修改业务描述";
			})
		},
		// 内勤派单   特勤派单
		dispatchOders(row, type) {
			this.reset();
			this.dispatchType = 'add';
			this.form.companyName = row.partyName;
			this.form.callName = row.callName;
			this.form.callPhone = row.callPhone;
			this.form.taskType = type;
			this.form.contractId = row.id;
			this.dispatchData.forEach(element => {
				if (element.name == 'companyName') {
					element.value = row.partyName;
				}
				if (element.name == 'callName') {
					element.value = row.callName;
				}
				if (element.name == 'callPhone') {
					element.value = row.callPhone;
				}
				if (element.name == 'paymentType') {
					// 判断合同未付金额是否大于0  大于0表示已收款项为定金，等于0表示已收款项为全款
					if (row.unPaidAmount > 0) {
						element.value = 0;
					} else {
						element.value = 1;
					}
				}
			});
			this.insideTaskVis = true;
			if (type === 1) {
				this.taskVisTitle = "内勤派单";
			} else {
				this.taskVisTitle = "特勤派单";
			}
			this.getcontractItem(row.id);
		},
		// 获取已生成合同的服务项目
		getcontractItem(id) {
			let that = this;
			//获取上次合同的服务项目
			contractItem(id).then((res) => {
				let groupIds = [];
				let contractArray = res.data;
				// 判断合同生成的服务项目是否有包含托管项目，有则设置 是否代账的值为是，无则设置为否
				let proxyVal = 1;
				for (let i = 0; i < contractArray.length; i++) {
					if (contractArray[i].groupId !== null) {
						proxyVal = 0;
						break
					}
				}
				this.dispatchData.forEach(element => {
					if (element.name == 'proxyIs') {
						element.value = proxyVal;
					}
				});
			})
		},
		// 内勤派单关闭
		insideTaskFormClose() {
			this.insideTaskVis = false;
			this.reset();
		},
		// 获取当前年-月-日函数
		getNowFormatDate() {
			var date = new Date();
			var seperator1 = "-";
			var year = date.getFullYear();
			var month = date.getMonth() + 1;
			var strDate = date.getDate();
			if (month >= 1 && month <= 9) {
				month = "0" + month;
			}
			if (strDate >= 0 && strDate <= 9) {
				strDate = "0" + strDate;
			}
			var currentdate = year + seperator1 + month + seperator1 + strDate;
			return currentdate;
		},
		// 内勤派单提交
		insideTaskFormConfirm() {
			this.$refs["elForm"].validate((valid) => {
				if (valid) {
					this.dispatchData.forEach(element => {
						// 如果name属性为gmtCreate，则检查其value值，如果为空需要设置value值为当前年月日
						if (element.name == 'gmtCreate' && element.value == '') {
							element.value = this.getNowFormatDate();
						}
						this.form[element.name] = element.value;
					});
					// 根据dispatchType值判断是新增还是修改
					this.loading = true;
					if (this.dispatchType == 'add') {
						this.form.contractTypeArr = this.form.selectList.toString();
						addTask(this.form).then((response) => {
							this.$modal.msgSuccess("派单成功");
							this.loading = false;
							this.getList();
							this.insideTaskVis = false;
							this.reset();
						});
					} else {
						updateTask(this.form).then((response) => {
							this.$modal.msgSuccess("修改成功");
							this.loading = false;
							this.getList();
							this.insideTaskVis = false;
							this.reset();
						});
					}
				} else {
					this.$modal.msgError("验证未通过");
					return false;
				}
			});
		},
		// 表单重置
		reset() {
			this.dispatchType = '';
			this.form = {
				paymentDate: '',
				companyName: null,//
				callName: null,//
				callPhone: null,//
				paymentType: null,//
				selectList: [],
			};
			this.dispatchData.forEach(element => {
				element.value = '';
				this.form[element.name] = '';
			});
			this.resetForm("elForm");
			// this.$refs.contractForm.clearValidate();
			// this.$refs.contractForm.resetFields();
		},
		// 单选元素点击时
		radioChange(e) {
			// this.form[e.name] = e.value;
			// console.log(this.form[e.name]);
		},
		// 元素输入时
		dispatchEvent(e) {
			// this.form[e.name] = e.value;
		},
		// 非托管类 提交审核
		submitAuditing(row, type) {
			if (row.sealStatus !== 1) {
				this.$modal.msgError("该合同未盖章，无法提交审核");
				return;
			}
			this.notesShow = true;
			this.formRemark.row = row;
			this.formRemark.type = type;
		},
		// 处理中合同  回传合同
		goBankContract(row) {
			if (row.sealStatus !== 1) {
				this.$modal.msgError("该合同未盖章，无法回传");
				return;
			}
			this.fileOpen = true;
			this.form.customId = row.id;
		},
		/** 申请作废 同意  拒绝 */
		applicationInvalidation(row, type) {
			let text;
			if (type === 7) {
				text = "确认同意吗？";
			} else {
				text = "确认拒绝吗？";
			}
			this.$modal
				.confirm(text)
				.then(function () { })
				.then(() => {
					let form = row;
					form.contractStatus = type;
					updateInfo(form).then((response) => {
						console.log(response);
						if (response.code === 200) {
							this.getList();
							this.$modal.msgSuccess("操作成功");
						}
					});
				})
				.catch(() => { });
		},
	},
};
</script>

<style scoped>
.el-row {
	margin-bottom: 20px;
}

.newTree /deep/ .el-tree-node__content {
	height: 40px !important;
}

.newdialog .el-row {
	margin-bottom: 0px !important;
}

.width18 {
	width: 180px;
}

.item-content /deep/ .pdfjs {
	height: 800px !important;
}

.upload-demo /deep/ .el-upload {
	width: 100% !important;
}

.el-button /deep/ .ali-iconhuichuan {
	font-size: 12px;
	margin-right: 5px;
}

.el-button /deep/ .ali-icontijiao {
	font-size: 14px;
	margin-right: 3px;
}

.el-button /deep/ .ali-iconzuofei {
	font-size: 12px;
	margin-right: 3px;
}

.el-dialog__wrapper .el-dialog .el-dialog__body {
	height: 75vh;
	overflow: auto;
}

.el-input--suffix /deep/ .el-input__inner {
	padding-right: 25px !important;
}
</style>